<{include file="public/header" /}>
<div class="layui-tab layui-tab-card" style="margin-top: -1px;">
  <ul class="layui-tab-title">
    <li class="layui-this">标题</li>
  </ul>
  <div class="layui-tab-content">
    <!-- 单选题选项卡1 -->
    <div class="layui-tab-item layui-show">
		<!-- <fieldset class="layui-elem-field layui-field-title" style="margin-top: 10px;">
          <legend>添加标题</legend>
      </fieldset> -->
      <form class="layui-form" lay-filter="editform">

          <div class="layui-form-item">
            <label class="layui-form-label">标题：</label>
            <div class="layui-input-block">
              <input type="text" name="qtitle" lay-verify="required" placeholder="如：一、选择题（共8个小题，每小题4分，共32分）" autocomplete="off" class="layui-input" >
            </div>
          </div>
           
          <div class="layui-form-item">
                <input type="hidden" name="qid" id="qid" value="<{$qdata.qid}>">
          </div>

          

          <div class="layui-form-item">
            <div class="layui-input-block">
              <button class="layui-btn" lay-submit lay-filter="titlesub">立即提交</button>
              <!-- <button type="reset" class="layui-btn layui-btn-primary">重置</button> -->
            </div>
          </div>
          <div style="height: 150px;"></div>
      </form>
  </div>
</div>
</div>
      <script>

layui.use(['form','element','layer','jquery'], function(){
  var $ = layui.$,element = layui.element,form = layui.form,layer = layui.layer;
  //----------上面引入layui下面开始业务，分割一下-----------------//
   
   //监听表单提交
  form.on('submit(titlesub)', function(data){
      //console.log(data.field);

     // layer.alert(JSON.stringify(data.field), {
     //    title: '最终的提交信息'
     //  });
    
    
        layer.confirm('确定提交?', {btn: ['提交','取消'],btnAlign: 'c', title:'请确认'}
        ,function(index){
          //do something
            $.post("<{:url('title_edit')}>",data.field,function(data,status){
              //alert(data);
              //alert(JSON.stringify(data));
             // console.log(data);
              if(data===1){
                //layer.close(index);
                layer.msg('修改成功!',function(){
                  x_father_close();
                   parent.location.reload();
                }); 
              }else{
                  layer.alert('修改失败，请刷新重试！');
              }
                
              
           })
          
        }); 
        return false; 
   });
  
//初始化数据
  form.val("editform", {
    "qtitle":"<{$qdata['qtitle']}>"// "name": "value"
    
  })

});


</script>